home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / setcurs.zip / BINTEST.ASM < prev    next >
Assembly Source File  |  1991-01-04  |  6KB  |  278 lines

  1. ;*
  2. ;*      Bintest.Asm - template for creating dbV bins
  3. ;*    Using QuickAsm
  4. ;*
  5. ;*      This template has 2 uses:
  6. ;*
  7. ;*    1. With Make Option set to debug
  8. ;*       it creates a standalone .COM file, that is easily debugged
  9. ;*
  10. ;*    2. With Make Option set to Release
  11. ;*       it creates an .OBJ file that can then be linked & exe2bin'ed
  12. ;*       Note: QC cannot generate the BIN file you must:
  13. ;*         LINK BINTEST;
  14. ;*         EXE2BIN BINTEST
  15. ;*         RENAME BINTEST.BIN TO <whatever>
  16.  
  17. NumParms = 2                            ; specify the number of parameters
  18.                                         ;    to be passed to BIN
  19.                                         ; place test parameters in P1, P2, etc.
  20.  
  21.     .Model Tiny,Pascal              ; Saves space
  22.  
  23.     .Code
  24.  
  25. ;* .COM code only
  26.  
  27. IFNDEF NDEBUG    ; This code is compiled for the QC2.5 Enviornment
  28.  
  29.     .StartUp
  30.  
  31.     ; Emulate dBASE parameter passing convention
  32.  
  33.     Mov     Cx,NumParms ; Number of parameters
  34.  
  35.     Mov     PB1,Cs      ; Fixup for parameters
  36.     Mov     Pb2,Cs      ;       .
  37.     Mov     Pb3,Cs      ;       .
  38.     Mov     Pb4,Cs      ;       .
  39.     Mov     Pb5,Cs      ;       .
  40.     Mov     Pb6,Cs      ;       .
  41.     Mov     Pb7,Cs      ;       .
  42.  
  43.     Lea     Di,PB       ;   ES is already set (via .Model Tiny)
  44.     Call    Main        ; Call Bin routine
  45.     .Exit
  46. ELSE
  47.  
  48. ;* .BIN code only
  49.  
  50.     %Out Build for dBASE IV BIN File
  51.     Org 0
  52.     Int     03h         ; For Debbuging purposes
  53. ENDIF
  54.  
  55. IFNDEF NDEBUG
  56.     ;* .COM only
  57.     Main   Proc
  58. ELSE
  59.     ;* .BIN only
  60.     Main   Proc    Far
  61. ENDIF
  62.  
  63. ;* Common code
  64.  
  65.         PARAM1  EQU   ES:[DI+0]
  66.         PARAM2  EQU   ES:[DI+4]
  67.         PARAM3  EQU   ES:[DI+8]
  68.         PARAM4  EQU   ES:[DI+12]
  69.         PARAM5  EQU   ES:[DI+16]
  70.         PARAM6  EQU   ES:[DI+20]
  71.         PARAM7  EQU   ES:[DI+24]
  72.  
  73. START:
  74.  
  75.     Push    Bp                  ; Save stack frame
  76.     Mov     Bp, Sp
  77.  
  78.     ; Quit if there not the correct number of parameters.
  79.  
  80.     Cmp     Cx, NumParms
  81.     Je      @F
  82.     Jmp     Short Done
  83. @@:
  84.     Push    Ds
  85.     Mov     Ax, Cs
  86.     Mov     Ds, Ax        ;* Ds addressability <easier to think>
  87.  
  88. IFNDEF NDEBUG
  89.         Call    SaveState
  90.         Push     Es
  91.         Push     Di
  92. ENDIF
  93.  
  94.  
  95. ;****************************************************************
  96. ;*
  97. ;* Actual bin routines go here.
  98. ;*
  99. ;****************************************************************
  100.  
  101. ; This routine, when LOADed and CALLed from DB4, will turn the
  102. ; cursor on and off, as well as toggle from an underline style
  103. ; cursor to a block cursor.
  104. ; Examples:
  105. ;    CALL setcurs WITH "F"      && turns off the cursor
  106. ;    CALL setcurs WITH "O","B"  && turns on a block cursor
  107. ;    CALL setcurs WITH "O","U"  && turns on a standard cursor
  108.  
  109.  
  110.         LDS     BX, PARAM1              ; DS:BX -> 1'st param
  111.         CMP     BYTE PTR [BX],'F'       ; cursor OFF?
  112.         JNE     ON                      ; no, turn cursor on
  113.         MOV     CX,200Fh                ; else turn it off code in CX
  114.         JMP     SHORT CALLROM           ; call the BIOS
  115. ON:
  116.         MOV     CX, 0011h               ; assume block cursor
  117.         LDS     BX, PARAM2              ; DS:BX -> 2'nd param
  118.         CMP     BYTE PTR [BX],'B'       ; Block cursor?
  119.         JE      CALLROM                 ; yes, jump
  120.         INT     11h                     ; find out what kind of equip.
  121.         MOV     CX,0607h                ; assume color scan lines
  122.         AND     AL,10h                  ; check tho
  123.         JZ      CALLROM                 ; OK? jump
  124.         MOV     CX,0B0Ch                ; whoops, set mono scan lines
  125. CALLROM:
  126.         MOV     AH,01
  127.         INT     10h
  128.  
  129.  
  130.  
  131. ;****************************************************************
  132. ;*
  133. ;*          End of BIN
  134. ;*
  135. ;****************************************************************
  136.  
  137. ;* .COM code only
  138.  
  139. IFNDEF NDEBUG    ; This code is compiled for the QC2.5 Enviornment
  140.          ; so we can determine if we have in fact done anything
  141.          ; Simply prints each of the resulting parameters
  142.  
  143.         Mov     Ah, 01h                 ; pause, press a key
  144.         Int     21h
  145.  
  146.         Pop     Di
  147.         Pop     Es
  148.         Call    VerifyState
  149.  
  150.     Mov    Cx,NumParms
  151.     Xor    Bx,Bx
  152. NextParm:
  153.     Lds    Dx,Es:[Di+Bx]
  154.     Mov    Si,Dx
  155.  
  156. @@:
  157.     Cmp    Byte Ptr [Si],0
  158.     Je    @F
  159.     Inc    Si
  160.     Jmp    Short @B
  161. @@:
  162.     Mov    Byte Ptr [Si],'$'
  163.     Mov     Ah,09h
  164.     Int     21h
  165.     Lea    Dx,CrLf
  166.     Int    21h
  167.     Add    Bx,4
  168.     Loop    NextParm
  169.  
  170. Endif
  171.  
  172. ;* Common code
  173.  
  174. Done:
  175.     Pop     Ds
  176.     Pop     Bp                ; Restore stack frame
  177.     Ret
  178.  
  179. Main  Endp
  180.  
  181. ;* .COM code only
  182.  
  183. IFNDEF NDEBUG
  184.  
  185. ;* Saves lengths of all parameters
  186.  
  187. SaveState    Proc
  188.  
  189.     Push    Di
  190.     Mov    Cx,NumParms
  191.     Lea    Bx,ParmLen
  192. NextParm:
  193.     Lds    Dx,Es:[Di]
  194.     Mov    Si,Dx
  195. @@:
  196.     Cmp    Byte Ptr [Si],0
  197.     Je    @F
  198.     Inc    Si
  199.     Jmp    Short @B
  200. @@:
  201.     Mov    Ax,Si
  202.     Sub    Ax,Dx
  203.     Mov    Byte Ptr [Bx],Al
  204.     Inc    Bx
  205.     Loop    NextParm
  206.     Pop    Di
  207.     Ret
  208. SaveState    Endp
  209.  
  210. VerifyState    Proc
  211.  
  212.     Push    Di
  213.     Mov    Cx,NumParms
  214.     Lea    Bx,ParmLen
  215. NextParm:
  216.     Lds    Dx,Es:[Di]
  217.     Mov    Si,Dx
  218. @@:
  219.     Cmp    Byte Ptr [Si],0
  220.     Je    @F
  221.     Inc    Si
  222.     Jmp    Short @B
  223. @@:
  224.     Mov    Ax,Si
  225.     Sub    Ax,Dx
  226.     Cmp    Byte Ptr [Bx],Al
  227.     Je    @F
  228.     Mov    Ah,09h
  229.     Lea    Dx,Warning
  230.     Int    21h
  231. @@:
  232.     Inc    Bx
  233.     Loop    NextParm
  234.     Pop    Di
  235.     Ret
  236.  
  237.     Ret
  238. VerifyState    Endp
  239.  
  240. ; INSERT TEST PARAMETERS HERE
  241. ;****************************
  242.  
  243.         P1      Db 'O',0
  244.         P2      Db 'B',0
  245.         P3      DB 0
  246.         P4      DB 0
  247.     P5      DB 0
  248.     P6      DB 0
  249.     P7      Db 0
  250.  
  251. ;****************************
  252.  
  253.     PB      Label Word
  254.         DW  Offset P1
  255.     PB1     Dw  ?
  256.         Dw  Offset P2
  257.     Pb2     Dw  ?
  258.         DW  Offset P3
  259.     PB3     Dw  ?
  260.         Dw  Offset P4
  261.     Pb4     Dw  ?
  262.         Dw  Offset P5
  263.     PB5     Dw  ?
  264.         Dw  OffSet P6
  265.     PB6     Dw  ?
  266.         DW  OffSet P7
  267.     PB7     Dw  ?
  268.  
  269. CrLf    Db    13,10,'$'
  270. Warning Db    7,13,10
  271.     Db    '** WARNING ** Length of passed parameters has changed!'
  272.     Db    13,10,'$'
  273. ParmLen    Db    7 dup (0)        ; Array of parameter lengths
  274.                     ; @ call time
  275. ENDIF
  276.  
  277.         END
  278.